Skip to content

test: Add pytest-xdist to execute tests in parallel on CI (and/or locally)#2672

Merged
mpangrazzi merged 4 commits into
mainfrom
opensearch_parallel_tests
Jan 9, 2026
Merged

test: Add pytest-xdist to execute tests in parallel on CI (and/or locally)#2672
mpangrazzi merged 4 commits into
mainfrom
opensearch_parallel_tests

Conversation

@mpangrazzi
Copy link
Copy Markdown
Contributor

Proposed Changes:

I've added pytest-xdist which distributes tests on N different workers for faster execution. On my Mac M3 Pro I can get tests executed ~75% faster. (35s vs 2m 15s on avg).

How did you test it?

unit tests, integration tests

Notes for the reviewer

By default, tests will be still run serially. To run them concurrently, you must add -n option. For example:

hatch run test:integration -n auto  # workers == available cores
hatch run test:all -n 4  # using 4 workers

Checklist

@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Jan 8, 2026
@davidsbatista
Copy link
Copy Markdown
Contributor

@mpangrazzi thanks for this 👍🏽

Could you quickly check if in our tests that depend on hosted instances, each (os/python version) is using a unique index name, those are the hosted doc stores:

  • Astra
  • AzureAISearch
  • Chroma
  • ElasticSearch
  • OpenSearch
  • PineCone
  • Weaviate

@mpangrazzi
Copy link
Copy Markdown
Contributor Author

@davidsbatista I would first use this approach on any IT tests which don't use hosted instances, since it's easier to detect issues (if any). For instance, I think it could be applied safely also to ES integration. For others, I would do that without hurry, when one has the chance to work on an integration which has relatively slow tests. WDYT?

cc @anakin87

@davidsbatista
Copy link
Copy Markdown
Contributor

@davidsbatista I would first use this approach on any IT tests which don't use hosted instances, since it's easier to detect issues (if any). For instance, I think it could be applied safely also to ES integration. For others, I would do that without hurry, when one has the chance to work on an integration which has relatively slow tests. WDYT?

cc @anakin87

agree: ElasticSearch, OpenSearch and Qdrant are all good candidates - high usage and can all run locally

@mpangrazzi mpangrazzi marked this pull request as ready for review January 9, 2026 13:30
@mpangrazzi mpangrazzi requested a review from a team as a code owner January 9, 2026 13:30
@anakin87 anakin87 changed the title Add pytest-xdist to execute tests in parallel on CI (and/or locally) test: Add pytest-xdist to execute tests in parallel on CI (and/or locally) Jan 9, 2026
Comment thread integrations/opensearch/tests/test_document_store.py
from haystack_integrations.document_stores.opensearch.document_store import OpenSearchDocumentStore


def _get_unique_index_name(request) -> str:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we simplify this? I am thinking of generating a UUID or something similar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I initially though that having the test name as the index name may help. But on a second though, we can also use an UUID without issues.

@mpangrazzi mpangrazzi requested a review from anakin87 January 9, 2026 14:59
Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@mpangrazzi mpangrazzi merged commit 8094d0d into main Jan 9, 2026
7 checks passed
@mpangrazzi mpangrazzi deleted the opensearch_parallel_tests branch January 9, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:opensearch topic:CI type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants